<?php

declare(strict_types=1);

namespace App\CustHub\Controller;

use App\CustHub\Annotation\VerifySignature;
use App\CustHub\Request\ConfigRequest;
use App\CustHub\Request\ContactBlackRequest;
use App\CustHub\Service\ChConfigService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;

#[Controller(prefix: 'ch/config'),VerifySignature]
class ChConfigController extends BaseController
{
    public array $noNeedVerifySign = ['getConfig'];

    #[Inject]
    protected ChConfigService $service;


    #[PostMapping('getConfig')]
    public function getConfig()
    {
        return $this->success($this->service->getConfig());
    }

    #[PostMapping('getConfigByGroup')]
    public function getConfigByGroup(ConfigRequest $request)
    {
        return $this->success($this->service->getConfigByGroupKey($request->input('uid'),$request->input('main_uid'),$request->input('group')));
    }

    #[PostMapping('saveConfig')]
    public function saveConfig(ConfigRequest $request)
    {
        return $this->service->saveConfig($request->all()) ? $this->success() : $this->error();
    }
}